set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# NPU
if(DEVICE STREQUAL "NPU")
    set(INC_PATH "/usr/local/Ascend/ascend-toolkit/8.1.RC1")
    message(STATUS "set default INC_PATH: ${INC_PATH}")

    set(LIB_PATH "/usr/local/Ascend/ascend-toolkit/8.1.RC1/lib64")
    message(STATUS "set default LIB_PATH: ${LIB_PATH}")
endif()

# 创建静态库
add_library(common_lib STATIC
    src/Common.cpp
    src/Segment.cpp
    src/ConfigLoader.cpp
    src/ThreadPool/ThreadPool.cpp
    include/Logger.h
    include/ConfigLoader.h
    include/ThreadPool/SafeQueue.h
    include/ThreadPool/ThreadPool.h
)

# 公开头文件目录
target_include_directories(common_lib PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${INC_PATH}/include
)

# 链接依赖库（如果有）
if(DEVICE STREQUAL "GPU")
    target_include_directories(common_lib PRIVATE ${CUDA_INC_DIR})
    target_link_libraries(common_lib PRIVATE ${CUDA_LIBRARIES})
elseif(DEVICE STREQUAL "NPU")
    target_link_libraries(common_lib PRIVATE ${LIB_PATH}/libascendcl.so)
endif()             